import Vue from 'vue'
import VueRouter from 'vue-router'
import ArticleList from '../views/ArticleList'
import Login from "../views/Login";
import Register from "../views/Register";
import Home from "../views/Home";
import EmailReg from "../components/EmailReg";
import PhoneReg from "../components/PhoneReg";
import User from "../views/User";
import ArticleItem from "../components/ArticleItem";
import Admin from "../views/Admin";
import UserInfo from "../components/UserInfo";
import ArticleInfo from "../components/ArticleInfo";

Vue.use(VueRouter)

const routes = [
  {
    path: "/",
    name: "Home",
    component:Home,
    children:[
      {
        path: "/login",
        name: "Login",
        component: Login
      },
      {
        path: "/register",
        name: "Register",
        component: Register,
        children:[
          {
            path: "/",
            alias: "/email",
            name: "Email",
            component: EmailReg
          },
          {
            path: "/phone",
            name: "Phone",
            component: PhoneReg
          },
        ]
      },
      {
        path: "/",
        name: "ArticleList",
        component: ArticleList
      },
      {
        path: "/user",
        name: "User",
        component: User
      },
      {
        path: "/article/:id",
        name: "Article",
        component: ArticleItem
      },
      {
        path: "/admin",
        component: Admin,
        children: [
          {
            path: '/admin/userInfo',
            component: UserInfo
          },
          {
            path: '/admin/articleInfo',
            component: ArticleInfo
          },
          {
            path: '/admin/',
            component: UserInfo
          },
          {
            path: "/article/:id",
            name: "Article",
            component: ArticleItem
          }
        ]
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
